<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='用户管理',active='user'">
<header th:replace="/header::headerFragment(${title},${active})"></header>
<body class="fixed-left">
<div id="wrapper">
    <div th:replace="/header::header-body"></div>
    <div class="content-page">
        <div class="content">
            <div class="container">
                <div class="row">
                    <div class="col-sm-12">
                        <h4 class="page-title">用户管理</h4>
                    </div>
                    <div class="col-md-12">
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th>账号</th>
                                <th>姓名</th>
                                <th>年龄</th>
                                <th>性别</th>
                                <th width="35%">地址</th>
                                <th width="15%">手机</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <th:block th:each="post : ${users.list}">
                                <tr th:cid="${post.userId}">
                                    <td><th:block th:text="${post.account}"/></td>
                                    <td><th:block th:text="${post.name}"/></td>
                                    <td><th:block th:text="${post.age}"/></td>
                                    <td><th:block th:text="${post.gender}"/></td>
                                    <td><th:block th:text="${post.addr}"/></td>
                                    <td><th:block th:text="${post.phone}"/></td>

                                    <td>
                                        <a href="javascript:void(0)" th:onclick="'delPost('+${post.userId}+');'"
                                           class="btn btn-danger btn-sm waves-effect waves-light m-b-5"><i
                                                class="fa fa-trash-o"></i> <span>删除</span></a>
                                    </td>
                                </tr>
                            </th:block>

                            </tbody>
                        </table>
                        <!--<div th:replace="comm/macros :: pageAdminNav(${articles})"></div>-->
                    </div>
                    <div class="btn-pre-next">
                        <div class="div-inline" th:if="!${users.isFirstPage}">
                            <button type="button" class="btn btn-primary waves-effect waves-light"
                                    th:onclick="'prePageClick('+${users.prePage}+');'">
                                上一页
                            </button>
                        </div>
                        <div class="div-inline" th:if="!${users.isLastPage}">
                            <button type="button" class="btn btn-primary waves-effect waves-light"
                                    th:onclick="'prePageClick('+${users.nextPage}+');'">
                                下一页
                            </button>
                        </div>

                    </div>
                </div>
                <div th:replace="/footer :: footer-content"></div>
            </div>
        </div>
    </div>
</div>
<div th:replace="/footer :: footer"></div>
<script type="text/javascript" >
    /*<![CDATA[*/
    var tale = new $.tale();
    function delPost(cid) {
        tale.alertConfirm({
            title:'确定删除该用户吗?',
            then: function () {
                tale.post({
                    url : '/admin/deleteUser',
                    data: {userId: cid},
                    success: function (result) {
                        if(result && result.success){
                            tale.alertOkAndReload('用户删除成功');
                            window.location.href = '/admin/index/1';
                        } else {
                            tale.alertError(result.msg || '用户删除失败');
                        }
                    }
                });
            }
        });
    }

    function prePageClick(page) {
        window.location.href = '/admin/index/'+page;
    }
    /*]]>*/
</script>
</body>
</html>